home *** CD-ROM | disk | FTP | other *** search
- program JoystickDemo;
- uses CRT,Joystick;
-
- var
- X, OX : byte;
- Y, OY : byte;
-
- procedure UnHighLight(X,Y : byte);
- begin
- Mem[$B800 : ((Y-1)*160)+((X)*2)-1]:=$0F; { Unhighlight & highlight }
- end; { Changes attrib at (X,Y) }
-
- procedure HighLight(X,Y : byte);
- begin
- Mem[$B800 : ((Y-1)*160)+((X)*2)-1]:=$4F;
- end;
-
- begin
- BetterInitJS(2); { Initialize the joystick }
- TextMode(CO80); { Set to 80x25 color mode }
- TextBackground(Black); { Set up colors..... }
- TextColor(White);
- ClrScr;
- Writeln('JonSoft Joystick Unit for Turbo Pascal - press any key to end');
- Window(32,5,50,12);
- Writeln('\ /'); { Make joystick 8-direction pattern }
- Writeln('');
- Writeln('');
- Writeln(' C ',chr(26));
- Writeln('');
- Writeln('');
- Writeln('/ \');
- Window(1,1,80,25);
- GotoXY(20,14); { Set up indicators }
- Writeln('Button 1 : released Button 2 : released');
- GotoXY(33,18);
- Writeln('X : xxx Y : xxx');
- repeat
- GotoXY(37,18);
- Write(JoyX,' '); { Update X and Y on the screen }
- GotoXY(47,18);
- Write(JoyY,' ');
- GotoXY(31,14);
- If Button1=1 then write('PRESSED ') { Update button info onscreen }
- else write('released');
- GotoXY(53,14);
- If Button2=1 then write('PRESSED ')
- else write('released');
- OX:=X;
- OY:=Y;
- Case Horiz of { Check 8-direction info, update on screen }
- -1 : X:=32;
- 0 : X:=40;
- 1 : X:=48;
- end;
- Case Vert of
- -1 : Y:= 5;
- 0 : Y:= 8;
- 1 : Y:= 11;
- end;
- Unhighlight(OX,OY);
- Highlight(X,Y);
- until keypressed { Exit when user pressed any key }
- end.